using System;
using System.Collections.Generic;
using System.Text;
using JobShopModel.GraphicInterface;

//TODO Explain the Observable/Observer system
namespace JobShopModel.Model.FactoryLvl
{
    /// <summary>
    /// Class used to implement Observer Design Patern.
    /// Must be implemented by every elements that have data show by the GUI
    /// </summary>
    public class Observable
    {
        private List<Observer> observerList;

        /// <summary>
        /// Add an observer
        /// </summary>
        /// <param name="obs">Observer</param>
        public void addObserver(Observer obs)
        {
            if (this.observerList == null)
                observerList = new List<Observer>();

            this.observerList.Add(obs);
        }

        /// <summary>
        /// Called by the implementing class to tell the GUI its state changed
        /// </summary>
        public void stateChanged()
        {
            foreach (Observer o in observerList)
            {
                o.update(this);
            }
        }

    }
}
